package cn.yunhe.crm.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.yunhe.crm.dao.BproductMapper;
import cn.yunhe.crm.entity.Aproduct;
import cn.yunhe.crm.entity.AproductExample;
import cn.yunhe.crm.entity.Bproduct;
import cn.yunhe.crm.entity.BproductExample;

/**
 * 
 * @author ����Ȫ
 *	B��Ʒ����
 */
@Service("bproductbiz")
public class BproductService {
		@Autowired
		private BproductMapper bproductdao;
		//����һ��B��Ʒ
		public void setBproductdao(BproductMapper bproductdao) {
			this.bproductdao =bproductdao;
		}
		
		public int addbproduct(Bproduct bproduct){
			int i=0;
			 try {
					i=bproductdao.insert(bproduct);
				} catch (Exception e) {
					i=0;
					e.printStackTrace();
				}
			return i;
		}
		//����һ��B��Ʒ
		public Bproduct getBproByCOid(Integer id) {
			BproductExample example=new BproductExample();
			example.createCriteria().andCoidEqualTo(id);
			return	bproductdao.selectByExample(example).get(0);
		}
		//�޸�һ��B��Ʒ
		public int updateBpro(Bproduct bproduct) {
			int i;
			 try {
				i=bproductdao.updateByPrimaryKeySelective(bproduct);
			} catch (Exception e) {
				i=0;
				e.printStackTrace();
			}
			return i;
		}
		public int checkCount(){
			
			return bproductdao.countByExample(null);
		}
}
